﻿namespace PMS.Client.FrmUserLeave
{
    using PMS.BLL;
    using PMS.Client.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmLogList : Form
    {
        private ToolStripButton btnCheck;
        private ToolStripButton btnDelete;
        private IContainer components = null;
        private UCDataGridView dataGridView1;
        private DataGridViewTextBoxColumn IUserName;
        private Label lbTitle;
        private DataGridViewTextBoxColumn LeaveDay;
        private DataGridViewTextBoxColumn LeaveReasion;
        private DataGridViewTextBoxColumn LeaveTo;
        private UserChangeLogBLL logbll = new UserChangeLogBLL();
        private DataGridViewTextBoxColumn LogID;
        private DataGridViewTextBoxColumn LogType;
        private DataGridViewTextBoxColumn PositionLevelDate;
        private DataGridViewTextBoxColumn PositionLevelNo;
        private DataGridViewTextBoxColumn PositionLevelRemark;
        private DataGridViewTextBoxColumn PositionLevelSummary;
        private ToolStrip toolStrip1;

        public FrmLogList()
        {
            this.InitializeComponent();
            this.dataGridView1.AutoGenerateColumns = false;
            this.DataGridBind();
        }

        private void btnCheck_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择要审核的记录！");
            }
            else
            {
                FrmLogCheck check = new FrmLogCheck(int.Parse(this.dataGridView1.SelectedRows[0].Cells["LogID"].Value.ToString()));
                check.ShowDialog();
                if (check.DialogResult == DialogResult.OK)
                {
                    this.DataGridBind();
                }
            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择要审核的记录！");
            }
            else if (MessageBox.Show("确定删除？", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                int logID = int.Parse(this.dataGridView1.SelectedRows[0].Cells["LogID"].Value.ToString());
                if (this.logbll.Delete(logID))
                {
                    this.DataGridBind();
                }
                else
                {
                    MessageBox.Show("删除失败！");
                }
            }
        }

        private void DataGridBind()
        {
            this.dataGridView1.DataSource = this.logbll.GetList(" AND LogType='减少'");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(FrmLogList));
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            this.toolStrip1 = new ToolStrip();
            this.btnCheck = new ToolStripButton();
            this.btnDelete = new ToolStripButton();
            this.dataGridView1 = new UCDataGridView(this.components);
            this.LogID = new DataGridViewTextBoxColumn();
            this.IUserName = new DataGridViewTextBoxColumn();
            this.LogType = new DataGridViewTextBoxColumn();
            this.LeaveReasion = new DataGridViewTextBoxColumn();
            this.LeaveDay = new DataGridViewTextBoxColumn();
            this.LeaveTo = new DataGridViewTextBoxColumn();
            this.PositionLevelNo = new DataGridViewTextBoxColumn();
            this.PositionLevelDate = new DataGridViewTextBoxColumn();
            this.PositionLevelSummary = new DataGridViewTextBoxColumn();
            this.PositionLevelRemark = new DataGridViewTextBoxColumn();
            this.lbTitle = new Label();
            this.toolStrip1.SuspendLayout();
            ((ISupportInitialize) this.dataGridView1).BeginInit();
            base.SuspendLayout();
            this.toolStrip1.Items.AddRange(new ToolStripItem[] { this.btnCheck, this.btnDelete });
            this.toolStrip1.Location = new Point(0, 0x1f);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.RenderMode = ToolStripRenderMode.System;
            this.toolStrip1.Size = new Size(0x3f0, 0x36);
            this.toolStrip1.TabIndex = 0x13;
            this.toolStrip1.Text = "toolStrip1";
            this.btnCheck.Image = (Image) manager.GetObject("btnCheck.Image");
            this.btnCheck.ImageScaling = ToolStripItemImageScaling.None;
            this.btnCheck.ImageTransparentColor = Color.Magenta;
            this.btnCheck.Name = "btnCheck";
            this.btnCheck.Size = new Size(0x24, 0x33);
            this.btnCheck.Text = "审批";
            this.btnCheck.TextImageRelation = TextImageRelation.ImageAboveText;
            this.btnCheck.Click += new EventHandler(this.btnCheck_Click);
            this.btnDelete.Image = (Image) manager.GetObject("btnDelete.Image");
            this.btnDelete.ImageScaling = ToolStripItemImageScaling.None;
            this.btnDelete.ImageTransparentColor = Color.Magenta;
            this.btnDelete.Name = "btnDelete";
            this.btnDelete.Size = new Size(0x24, 0x33);
            this.btnDelete.Text = "删除";
            this.btnDelete.TextImageRelation = TextImageRelation.ImageAboveText;
            this.btnDelete.Click += new EventHandler(this.btnDelete_Click);
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToResizeRows = false;
            this.dataGridView1.BackgroundColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            this.dataGridView1.BorderStyle = BorderStyle.None;
            this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.LogID, this.IUserName, this.LogType, this.LeaveReasion, this.LeaveDay, this.LeaveTo, this.PositionLevelNo, this.PositionLevelDate, this.PositionLevelSummary, this.PositionLevelRemark });
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            style.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style.ForeColor = SystemColors.ControlText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.ControlText;
            style.WrapMode = DataGridViewTriState.False;
            this.dataGridView1.DefaultCellStyle = style;
            this.dataGridView1.Dock = DockStyle.Fill;
            this.dataGridView1.EnableHeadersVisualStyles = false;
            this.dataGridView1.GridColor = Color.FromArgb(0xd0, 0xd7, 0xe5);
            this.dataGridView1.HighlightSelectedColumnHeaders = false;
            this.dataGridView1.Location = new Point(0, 0x55);
            this.dataGridView1.MultiSelect = false;
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.RowTemplate.Height = 0x17;
            this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.Size = new Size(0x3f0, 0x182);
            this.dataGridView1.TabIndex = 20;
            this.LogID.DataPropertyName = "LogID";
            this.LogID.HeaderText = "ID";
            this.LogID.Name = "LogID";
            this.LogID.ReadOnly = true;
            this.LogID.Visible = false;
            this.LogID.Width = 50;
            this.IUserName.DataPropertyName = "IUserName";
            this.IUserName.HeaderText = "姓名";
            this.IUserName.Name = "IUserName";
            this.IUserName.ReadOnly = true;
            this.LogType.DataPropertyName = "LogType";
            this.LogType.HeaderText = "日志类型";
            this.LogType.Name = "LogType";
            this.LogType.ReadOnly = true;
            this.LeaveReasion.DataPropertyName = "LeaveReasion";
            this.LeaveReasion.HeaderText = "减少原因";
            this.LeaveReasion.Name = "LeaveReasion";
            this.LeaveReasion.ReadOnly = true;
            this.LeaveReasion.Width = 150;
            this.LeaveDay.DataPropertyName = "LeaveDay";
            this.LeaveDay.HeaderText = "减少时间";
            this.LeaveDay.Name = "LeaveDay";
            this.LeaveDay.ReadOnly = true;
            this.LeaveTo.DataPropertyName = "LeaveTo";
            this.LeaveTo.HeaderText = "减少去向";
            this.LeaveTo.Name = "LeaveTo";
            this.LeaveTo.ReadOnly = true;
            this.PositionLevelNo.DataPropertyName = "LeaveNo";
            this.PositionLevelNo.HeaderText = "批文编号";
            this.PositionLevelNo.Name = "PositionLevelNo";
            this.PositionLevelNo.ReadOnly = true;
            this.PositionLevelNo.Width = 120;
            this.PositionLevelDate.DataPropertyName = "LeaveDate";
            this.PositionLevelDate.HeaderText = "下文时间";
            this.PositionLevelDate.Name = "PositionLevelDate";
            this.PositionLevelDate.ReadOnly = true;
            this.PositionLevelSummary.DataPropertyName = "LeaveSummary";
            this.PositionLevelSummary.HeaderText = "批文摘要";
            this.PositionLevelSummary.Name = "PositionLevelSummary";
            this.PositionLevelSummary.ReadOnly = true;
            this.PositionLevelSummary.Width = 130;
            this.PositionLevelRemark.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.PositionLevelRemark.DataPropertyName = "LeaveRemark";
            this.PositionLevelRemark.HeaderText = "备注";
            this.PositionLevelRemark.Name = "PositionLevelRemark";
            this.PositionLevelRemark.ReadOnly = true;
            this.lbTitle.BackColor = Color.Gold;
            this.lbTitle.Dock = DockStyle.Top;
            this.lbTitle.Font = new Font("宋体", 14.25f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbTitle.ForeColor = Color.Black;
            this.lbTitle.Location = new Point(0, 0);
            this.lbTitle.Name = "lbTitle";
            this.lbTitle.Size = new Size(0x3f0, 0x1f);
            this.lbTitle.TabIndex = 0x72;
            this.lbTitle.Text = "人员减少审核";
            this.lbTitle.TextAlign = ContentAlignment.MiddleCenter;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x3f0, 0x1d7);
            base.Controls.Add(this.dataGridView1);
            base.Controls.Add(this.toolStrip1);
            base.Controls.Add(this.lbTitle);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "FrmLogList";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "人员减少审核";
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            ((ISupportInitialize) this.dataGridView1).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

